/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.register.realname;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;
import com.qihoo.gamecenter.sdk.common.i.j;
import com.qihoo.gamecenter.sdk.common.i.s;
import com.qihoo.gamecenter.sdk.common.view.CustButton;
import com.qihoo.gamecenter.sdk.common.view.CustEditText;
import com.qihoo.gamecenter.sdk.login.plugin.d;
import com.qihoo.gamecenter.sdk.login.plugin.d.a;
import com.qihoo.gamecenter.sdk.login.plugin.f.a;
import com.qihoo.gamecenter.sdk.login.plugin.h.b;
import java.lang.ref.WeakReference;

public class RealNameRegisterView extends FrameLayout {
    private Activity a;
    private View b;
    private View c;
    private View d;
    private CustEditText e;
    private CustEditText f;
    private FrameLayout g;
    private LinearLayout h;
    private a i;
    private RealNameRegisterMainLayout.a j;
    private Handler k = new a(this);

    public RealNameRegisterView(Context paramContext) {
        super(paramContext);
        this.a = ((Activity) paramContext);
        d();
        e();
    }

    public RealNameRegisterView(Context paramContext, AttributeSet paramAttributeSet) {
        super(paramContext, paramAttributeSet);
    }

    public void setOperationListener(RealNameRegisterMainLayout.a parama) {
        this.j = parama;
        if (this.j == null)
            return;
        this.j.a(d.a(d.a.aU), d.a(d.a.aV), true);
    }

    private void d() {
        this.i = a.a(this.a);
    }

    private void e() {
        this.i.a(this, -1073741797);
        ScrollView localScrollView = new ScrollView(this.a);
        localScrollView.setFadingEdgeLength(0);
        localScrollView.setVerticalScrollBarEnabled(false);
        addView(localScrollView);
        this.g = new FrameLayout(this.a);
        localScrollView.addView(this.g);
        LinearLayout.LayoutParams localLayoutParams1 = new LinearLayout.LayoutParams(s.b(this.a, 320.0F), -2);
        localLayoutParams1.setMargins(0, s.b(this.a, 5.0F), 0, s.b(this.a, 5.0F));
        this.h = new LinearLayout(this.a);
        this.h.setOrientation(1);
        this.h.setPadding(s.b(this.a, 15.0F), s.b(this.a, 0.0F), s.b(this.a, 15.0F), s.b(this.a, 15.0F));
        this.g.addView(this.h, new FrameLayout.LayoutParams(-1, -1));
        LinearLayout.LayoutParams localLayoutParams2 = new LinearLayout.LayoutParams(-1, s.b(this.a, 47.0F));
        localLayoutParams2.setMargins(0, s.b(this.a, 5.0F), 0, s.b(this.a, 5.0F));
        this.h.addView(f());
        this.h.addView(g());
        LinearLayout localLinearLayout = new LinearLayout(this.a);
        LinearLayout.LayoutParams localLayoutParams3 = new LinearLayout.LayoutParams(0, -2);
        localLayoutParams3.weight = 1.0F;
        LinearLayout.LayoutParams localLayoutParams4 = new LinearLayout.LayoutParams(-2, -2);
        this.d = localLinearLayout;
        localLinearLayout.setOrientation(0);
        this.i.a(localLinearLayout, -1073741801);
        localLinearLayout.setPadding(s.b(this.a, 5.0F), s.b(this.a, 4.0F), s.b(this.a, 8.0F), s.b(this.a, 2.0F));
        localLinearLayout.setGravity(16);
        this.h.addView(localLinearLayout, localLayoutParams2);
        TextView localTextView = new TextView(this.a);
        localTextView.setTextColor(-16777216);
        localTextView.setText(d.a(d.a.aS));
        localTextView.setTextSize(1, 13.3F);
        localLinearLayout.addView(localTextView, localLayoutParams4);
        this.e = new CustEditText(this.a);
        this.e.setTextColor(-16777216);
        this.e.setSingleLine(true);
        this.e.setHintTextColor(-3355444);
        this.e.setHint(d.a(d.a.aU));
        this.e.setTextSize(1, 13.3F);
        this.e.setBackgroundColor(0);
        this.e.setInputType(1);
        this.e.setPadding(s.b(this.a, 10.0F), 0, 0, 0);
        this.e.c();
        this.e.d();
        this.e.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            public void onFocusChange(View paramView, boolean paramBoolean) {
                if (!(paramBoolean))
                    return;
                RealNameRegisterView.a(RealNameRegisterView.this).getWindow().setSoftInputMode(4);
                InputMethodManager localInputMethodManager = (InputMethodManager) RealNameRegisterView.a(
                        RealNameRegisterView.this).getSystemService("input_method");
                if (localInputMethodManager == null)
                    return;
                localInputMethodManager.showSoftInput(RealNameRegisterView.b(RealNameRegisterView.this), 1);
            }
        });
        localLinearLayout.addView(this.e, localLayoutParams3);
        ImageView localImageView1 = new ImageView(this.a);
        this.i.a(localImageView1, 1073741835);
        localImageView1.setVisibility(8);
        localImageView1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                RealNameRegisterView.b(RealNameRegisterView.this).setText("");
            }
        });
        localLinearLayout.addView(localImageView1,
                new LinearLayout.LayoutParams(s.b(this.a, 20.0F), s.b(this.a, 20.0F)));
        InputFilter[] arrayOfInputFilter1 = { new InputFilter.LengthFilter(4) };
        this.e.setFilters(arrayOfInputFilter1);
        this.e.a();
        this.e.b();
        this.e.addTextChangedListener(new TextWatcher(localImageView1) {
            public void onTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3) {
                j.a("RealNameRegisterView", "onTextChanged,current string is " + paramCharSequence, new Object[0]);
                RealNameRegisterView.c(RealNameRegisterView.this).removeMessages(104);
                if (TextUtils.isEmpty(paramCharSequence)) {
                    this.a.setVisibility(8);
                    RealNameRegisterView.d(RealNameRegisterView.this);
                    return;
                }
                this.a.setVisibility(0);
                if (!(RealNameRegisterView.a(RealNameRegisterView.this, String.valueOf(paramCharSequence))))
                    return;
                Message localMessage = RealNameRegisterView.c(RealNameRegisterView.this).obtainMessage(104);
                RealNameRegisterView.c(RealNameRegisterView.this).sendMessageDelayed(localMessage, 500L);
            }

            public void beforeTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3) {}

            public void afterTextChanged(Editable paramEditable) {
                if (RealNameRegisterView.a(RealNameRegisterView.this, String.valueOf(paramEditable)))
                    return;
                RealNameRegisterView.c(RealNameRegisterView.this).removeMessages(104);
                RealNameRegisterView.d(RealNameRegisterView.this);
            }
        });
        localLinearLayout = new LinearLayout(this.a);
        this.c = localLinearLayout;
        localLinearLayout.setOrientation(0);
        this.i.a(localLinearLayout, -1073741801);
        localLinearLayout.setPadding(s.b(this.a, 5.0F), s.b(this.a, 4.0F), s.b(this.a, 8.0F), s.b(this.a, 2.0F));
        localLinearLayout.setGravity(16);
        this.h.addView(localLinearLayout, localLayoutParams2);
        localTextView = new TextView(this.a);
        localTextView.setTextColor(-16777216);
        localTextView.setText(d.a(d.a.aT));
        localTextView.setTextSize(1, 13.3F);
        localLinearLayout.addView(localTextView, localLayoutParams4);
        this.f = new CustEditText(this.a);
        this.f.setTextColor(-16777216);
        this.f.setSingleLine(true);
        this.f.setHintTextColor(-3355444);
        this.f.setHint(d.a(d.a.aV));
        this.f.setTextSize(1, 13.3F);
        this.f.setBackgroundColor(0);
        this.f.setInputType(1);
        this.f.setPadding(s.b(this.a, 10.0F), 0, 0, 0);
        localLinearLayout.addView(this.f, localLayoutParams3);
        ImageView localImageView2 = new ImageView(this.a);
        this.i.a(localImageView2, 1073741835);
        localImageView2.setBackgroundColor(-1);
        localImageView2.setVisibility(8);
        localImageView2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                RealNameRegisterView.e(RealNameRegisterView.this).setText("");
            }
        });
        localLinearLayout.addView(localImageView2,
                new LinearLayout.LayoutParams(s.b(this.a, 20.0F), s.b(this.a, 20.0F)));
        InputFilter[] arrayOfInputFilter2 = { new InputFilter.LengthFilter(18) };
        this.f.setFilters(arrayOfInputFilter2);
        this.f.a();
        this.f.b();
        this.f.addTextChangedListener(new TextWatcher(localImageView2) {
            public void onTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3) {
                j.a("RealNameRegisterView", "onTextChanged,current id number is " + paramCharSequence, new Object[0]);
                if (TextUtils.isEmpty(paramCharSequence))
                    this.a.setVisibility(8);
                else
                    this.a.setVisibility(0);
                RealNameRegisterView.c(RealNameRegisterView.this).removeMessages(104);
                if (!(RealNameRegisterView.b(RealNameRegisterView.this, String.valueOf(paramCharSequence))))
                    return;
                Message localMessage = RealNameRegisterView.c(RealNameRegisterView.this).obtainMessage(105);
                RealNameRegisterView.c(RealNameRegisterView.this).sendMessageDelayed(localMessage, 500L);
            }

            public void beforeTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3) {}

            public void afterTextChanged(Editable paramEditable) {
                if (RealNameRegisterView.b(RealNameRegisterView.this, String.valueOf(paramEditable)))
                    return;
                RealNameRegisterView.c(RealNameRegisterView.this).removeMessages(105);
                RealNameRegisterView.d(RealNameRegisterView.this);
            }
        });
        localLinearLayout = new LinearLayout(this.a);
        localLinearLayout.setOrientation(0);
        this.h.addView(localLinearLayout, localLayoutParams1);
        LinearLayout.LayoutParams localLayoutParams5 = new LinearLayout.LayoutParams(-1, s.b(this.a, 47.0F));
        CustButton localCustButton = new CustButton(this.a);
        localCustButton.setText(d.a(d.a.aQ));
        localCustButton.a();
        localCustButton.b();
        localCustButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                RealNameRegisterView.f(RealNameRegisterView.this);
            }
        });
        localCustButton.setTextColor(-1);
        localCustButton.setTextSize(1, 13.3F);
        this.i.a(localCustButton, -1073741764, -1073741763, -1073741763);
        localCustButton.setPadding(s.b(this.a, 7.0F), s.b(this.a, 13.0F), s.b(this.a, 7.0F), s.b(this.a, 13.0F));
        this.h.addView(localCustButton, localLayoutParams5);
        a();
    }

    private LinearLayout f() {
        LinearLayout localLinearLayout = new LinearLayout(this.a);
        localLinearLayout.setGravity(1);
        LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-1, -2);
        localLayoutParams.topMargin = s.b(this.a, 14.0F);
        localLayoutParams.bottomMargin = s.b(this.a, 4.0F);
        localLinearLayout.setLayoutParams(localLayoutParams);
        ImageView localImageView = new ImageView(this.a);
        int l = s.b(this.a, 18.0F);
        localImageView.setLayoutParams(new FrameLayout.LayoutParams(l, l));
        localImageView.setScaleType(ImageView.ScaleType.FIT_XY);
        localImageView.setBackgroundDrawable(this.i.a(1073741873));
        localLinearLayout.addView(localImageView);
        TextView localTextView = new TextView(this.a);
        localTextView.setGravity(17);
        localTextView.setTextColor(Color.parseColor("#ff7f16"));
        localTextView.setTextSize(1, 14.0F);
        localTextView.setText(d.a(d.a.aP));
        localLinearLayout.addView(localTextView);
        return localLinearLayout;
    }

    private View g() {
        TextView localTextView = new TextView(this.a);
        localTextView.setPadding(0, 0, 0, s.b(this.a, 5.0F));
        localTextView.setText(d.a(d.a.aR));
        localTextView.setTextSize(1, 12.0F);
        localTextView.setTextColor(-16777216);
        return localTextView;
    }

    private void h() {
        String str1 = this.f.getText().toString();
        String str2 = this.e.getText().toString();
        if ((TextUtils.isEmpty(str2)) && (TextUtils.isEmpty(str1))) {
            if (this.j != null)
                if (this.j.a()) {
                    this.e.requestFocus();
                    a(d.a(d.a.aW), this.d);
                }
                else {
                    this.j.a(d.a(d.a.aU), d.a(d.a.aV), false);
                }
            return;
        }
        if (b(str2)) {
            this.e.requestFocus();
            a(d.a(d.a.aW), this.d);
            return;
        }
        if (c(str1)) {
            this.f.requestFocus();
            a(d.a(d.a.aX), this.c);
            return;
        }
        if (this.j == null)
            return;
        this.j.a(str2, str1, false);
    }

    private void a(String paramString, View paramView) {
        if (this.b != null)
            i();
        FrameLayout localFrameLayout = new FrameLayout(this.a);
        this.g.addView(localFrameLayout, new FrameLayout.LayoutParams(-1, -1));
        int l = paramView.getTop();
        TextView localTextView = new TextView(this.a);
        localTextView.setText(paramString);
        localTextView.setTextColor(Color.parseColor("#e46052"));
        this.i.a(localTextView, -1073741766);
        localTextView.setPadding(s.b(this.a, 10.0F), s.b(this.a, 3.0F), s.b(this.a, 10.0F), s.b(this.a, 3.0F));
        localTextView.setTextSize(1, 12.0F);
        localFrameLayout.addView(localTextView, new FrameLayout.LayoutParams(-2, -2));
        localTextView.setVisibility(4);
        localTextView.post(new Runnable(localFrameLayout, l, localTextView) {
            public void run() {
                this.a.setPadding(s.b(RealNameRegisterView.a(RealNameRegisterView.this), 30.0F),
                        this.b - this.c.getHeight(), s.b(RealNameRegisterView.a(RealNameRegisterView.this), 30.0F), 0);
                this.c.setVisibility(0);
            }
        });
        this.b = localFrameLayout;
    }

    private void i() {
        if (this.b == null)
            return;
        this.g.removeView(this.b);
        this.b = null;
    }

    public void a() {
        this.e.requestFocus();
    }

    public View b() {
        return this.c;
    }

    public View c() {
        return this.d;
    }

    private boolean b(String paramString) {
        return ((TextUtils.isEmpty(paramString)) || (paramString.length() > 4) || (paramString.length() < 2) || (!(a(paramString))));
    }

    private boolean c(String paramString) {
        return ((TextUtils.isEmpty(paramString)) || (!(b.b(paramString))));
    }

    public static boolean a(String paramString) {
        if ((null == paramString) || ("".equals(paramString.trim())))
            return false;
        for (int i1 = 0; i1 < paramString.length(); ++i1) {
            int l = paramString.charAt(i1);
            if ((l < 19968) || (l > 171941))
                return false;
        }
        return true;
    }

    private static class a extends Handler {
        private WeakReference a;

        public a(RealNameRegisterView paramRealNameRegisterView) {
            this.a = new WeakReference(paramRealNameRegisterView);
        }

        public void handleMessage(Message paramMessage) {
            RealNameRegisterView localRealNameRegisterView = (RealNameRegisterView) this.a.get();
            if (paramMessage.what == 104) {
                RealNameRegisterView.a(localRealNameRegisterView, d.a(d.a.aW), localRealNameRegisterView.c());
            }
            else {
                if (paramMessage.what != 105)
                    return;
                RealNameRegisterView.a(localRealNameRegisterView, d.a(d.a.aX), localRealNameRegisterView.b());
            }
        }
    }
}